var ATOMIC_CONFIG_NS = "http://www.atomojo.org/Vocabulary/Atomic/Configuration/2007/1/0";
var ATOMIC_OLD_CONFIG_NS = "http://www.smallx.com/Vocabulary/Atomic/Configuration/2006/1/0";


function AtomicConfig() {
   this.configURL = null;
   this.autoTitle = null;
   this.defaultType = null;
   this.logLevel = 3;
   
   /*
    * load the configuration
    */
   this.prefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.atomic.");
   try {
      this.configURL = this.prefBranch.getCharPref("default.config.url");
   } catch (e) {
      consoleService.logStringMessage("Cannot load preference 'default.config.url' due to: "+e);
   }
   try {
      this.autoTitle = this.prefBranch.getBoolPref("auto-title");
   } catch (e) {
      consoleService.logStringMessage("Cannot load preference 'auto-title' due to: "+e);
   }
   try {
      this.defaultType = this.prefBranch.getCharPref("default.type");
   } catch (e) {
      consoleService.logStringMessage("Cannot load preference 'default.type' due to: "+e);
   }
   try {
      this.logLevel = this.prefBranch.getIntPref("logLevel");
   } catch (e) {
      consoleService.logStringMessage("Cannot load preference 'logLevell' due to: "+e);
   }
}

AtomicConfig.prototype.updatePreferences = function() {
   this.prefBranch.setCharPref("default.config.url",this.configURL);
   this.prefBranch.setBoolPref("auto-title",this.autoTitle);
   this.prefBranch.setCharPref("default.type",this.defaultType);
   this.prefBranch.setIntPref("logLevel",this.lgoLevel);
}

AtomicConfig.prototype.load = function(options) {
   var url = this.configURL;
   var currentConfig = this;
   HTTP("GET",this.configURL,{
      overrideMimeType: "text/xml",
      onSuccess: function(status,document) {
         currentConfig.document = document;
         options.onSuccess(currentConfig);
      },
      onFailure: options.onFailure
   });
}